package app.netant.finishbook.shubao7;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
/**
 * 
 * @author JiaJ
 *
 */
public class Shubao7Detail extends BaseDetail {

	public Shubao7Detail(String netSite) {
		super(netSite);
		this.preHref = "http://www.shubaoz.com";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select(".main #centerl #content .p_vod .main_wrap .main.sec .detail .title h1.fl");
		if(parts.size()>0){
			String title = parts.get(0).text();
			System.out.println("【Title】:"+title);
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".txt");
		}
	}

	@Override
	public void analyseTags() {
		
		Elements titles = this.select(".main #centerl #content .p_vod .main_wrap .main.sec .detail ul li span");
		Elements values = this.select(".main #centerl #content .p_vod .main_wrap .main.sec .detail ul li p");
		
		for(int i=0;i<titles.size();i++){
			String tagName = titles.get(i).text();			
			if(values.size()<=i){
				break;
			}
			String tagValue = values.get(i).text();
			System.out.println("【Tag】："+tagName+"="+tagValue);
			this.entity.setTag(tagName, tagValue);
		}
		
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select(".main #centerl #content .p_vod .playlist .mlist");
		if(parts.size()>0){
			String memo = parts.get(0).text();
			System.out.println("【Memo】:"+memo);
			this.entity.setNovelMemo(memo);
		}
	}

	@Override
	public void analyseHref() {
		Elements parts = this.select(".main #centerl #content .p_vod .main_wrap .main.sec .l_b .fr a.fav");
		if(parts.size()>0){
			String href = parts.get(0).attr("href");
			if(href.startsWith("/")){
				href = this.preHref + href;
			}
			System.out.println("【Href】:"+href);
			this.entity.setDownPath(href);
		}
	}
	
	@Override
	public void analyseType() {
		Elements parts = this.select(".main #centerl #content .p_vod .breadnav_wrap .breadnav a");
		if(parts.size()>1){
			String type = parts.get(1).text();
			System.out.println("【Type】:"+type);
			this.entity.setNovelType(type);
		}
	}
	
	public static void main(String[] args) {
		Shubao7Detail detail = new Shubao7Detail("http://www.shubaoz.com/book/1.html");
		detail.test();
	}



}
